﻿@model List<CMSApplication.Areas.Administration.Models.WorkModel>
<script>
    jQuery(document).ready(function ($) {
        $("a.delete").click(function () {
            var $this = $(this);
            var item_id = $this.closest("tr").find(".Spanid").html();
            if (confirm("Bạn chắc chắn muốn xóa công việc: Mã = " + item_id + "?")) {
                $.get("/Work/Delete?Id=" + item_id, function () {
                    $.get("/Management/Wrk_NextTimes_List", function (data) {
                        $(".list").html("");
                        $(".list").html(data);
                    });
                });
            }
        });

        $("#ListTable").dataTable({
            "sPaginationType": "full_numbers",
            "iDisplayLength": 5,
            "bSortable": false,
            "aLengthMenu": [5, 10, 20],
        });
    });
</script>
<table class="table dataTable" style="width: 100%" id="ListTable">
    <thead>
        <th style="text-align:center;">Mã</th>
        <th>Khách hàng</th>
        <th>Địa chỉ</th>
        <th>Điện thoại</th>
        <th>Nhân viên</th>
        <th style="text-align:center;">Ngày thực hiện</th>
        <th style="text-align:center; width:50px;">Tác vụ</th>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td style="text-align:center;">
                    <span class="Spanid">@item.Id</span>
                </td>
                <td>
                    <span>@item.CustomerName</span>
                </td>
                <td>
                    <span>@item.CustomerAddr</span>
                </td>
                <td>
                    <span>@item.CustomerPhone</span>
                </td>
                <td>
                    <span>@item.StaffName</span>
                </td>
                <td style="text-align:center;">
                    <span>@string.Format("{0:dd/MM/yyyy}", item.AssignOn)</span>
                </td>
                <td style="text-align:center;">
                    <a title="Chỉnh sửa » @item.Id" href="@Url.Action("Edit", "Work", new { id = item.Id})" class="icon-pencil"></a>
                    <a title="Xóa bỏ » @item.Id" href="javascript:void(0)" class="icon-trash delete"></a>
                </td>
            </tr>
        }
    </tbody>
</table>
